package com.hzhr.iot.statis.convertor;

import com.hzhr.iot.statis.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.statis.model.deviceDataException.DeviceDataExceptionModel;
import com.hzhr.iot.statis.entity.DeviceDataExceptionEntity;
import com.hzhr.iot.statis.entity.ext.DeviceDataExceptionEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.statis.model.deviceDataException.DeviceDataExceptionModel;
import com.hzhr.iot.statis.model.deviceDataException.DeviceDataExceptionGetModel;
import com.hzhr.iot.statis.queryModel.custom.DeviceDataExceptionCustomQueryModel;

@Component
public class DeviceDataExceptionConvertor {
    @Autowired
    DeptDailyGasConsumeCustomConvertor deptDailyGasConsumeCustomConvertor;
    @Autowired
    DeptMonthlyGasConsumeCustomConvertor deptMonthlyGasConsumeCustomConvertor;
    @Autowired
    DeviceCollectDeviceCustomConvertor deviceCollectDeviceCustomConvertor;
    @Autowired
    DeviceDailyGasConsumeCustomConvertor deviceDailyGasConsumeCustomConvertor;
    @Autowired
    DeviceHourlyGasConsumeCustomConvertor deviceHourlyGasConsumeCustomConvertor;
    @Autowired
    DeviceIotDeviceCustomConvertor deviceIotDeviceCustomConvertor;
    @Autowired
    DeviceMonthlyGasConsumeCustomConvertor deviceMonthlyGasConsumeCustomConvertor;
    @Autowired
    GasUserDailyGasConsumeCustomConvertor gasUserDailyGasConsumeCustomConvertor;
    @Autowired
    GasUserMonthlyGasConsumeCustomConvertor gasUserMonthlyGasConsumeCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;

    public DeviceDataExceptionEntity deviceDataExceptionModel2entity(DeviceDataExceptionModel in) {
        //未转换字段: id 
        if (in == null) return null;
        DeviceDataExceptionEntity result = new DeviceDataExceptionEntity();

        result.setCollectDeviceId(HzhrTypeUtil.integer2integer(in.getCollectDeviceId()));
        result.setCollectDeviceCode(HzhrTypeUtil.string2string(in.getCollectDeviceCode()));
        result.setCollectDeviceCategoryCode(HzhrTypeUtil.string2string(in.getCollectDeviceCategoryCode()));
        result.setCollectDeviceDeptId(HzhrTypeUtil.integer2integer(in.getCollectDeviceDeptId()));
        result.setCollectDeviceDeptName(HzhrTypeUtil.string2string(in.getCollectDeviceDeptName()));
        result.setCollectDeviceResourceCode(HzhrTypeUtil.string2string(in.getCollectDeviceResourceCode()));
        result.setIotDeviceId(HzhrTypeUtil.integer2integer(in.getIotDeviceId()));
        result.setIotDeviceCode(HzhrTypeUtil.string2string(in.getIotDeviceCode()));
        result.setIotDeviceCategoryCode(HzhrTypeUtil.string2string(in.getIotDeviceCategoryCode()));
        result.setIotDeviceCompanyId(HzhrTypeUtil.integer2integer(in.getIotDeviceCompanyId()));
        result.setIotDeviceCompanyName(HzhrTypeUtil.string2string(in.getIotDeviceCompanyName()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        result.setGasUserCode(HzhrTypeUtil.string2string(in.getGasUserCode()));
        result.setExceptionDayCount(HzhrTypeUtil.integer2integer(in.getExceptionDayCount()));
        result.setExceptionType(HzhrTypeUtil.string2string(in.getExceptionType()));
        result.setStatisDate(HzhrTypeUtil.long2date(in.getStatisDate()));
        return result;
    }
    public DeviceDataExceptionEntity deviceDataExceptionModel2entity(DeviceDataExceptionModel in, DeviceDataExceptionEntity ori) {
        //未转换字段: id 
        if (in == null) return null;
        DeviceDataExceptionEntity result = ori;

        result.setCollectDeviceId(HzhrTypeUtil.integer2integer(in.getCollectDeviceId()));
        result.setCollectDeviceCode(HzhrTypeUtil.string2string(in.getCollectDeviceCode()));
        result.setCollectDeviceCategoryCode(HzhrTypeUtil.string2string(in.getCollectDeviceCategoryCode()));
        result.setCollectDeviceDeptId(HzhrTypeUtil.integer2integer(in.getCollectDeviceDeptId()));
        result.setCollectDeviceDeptName(HzhrTypeUtil.string2string(in.getCollectDeviceDeptName()));
        result.setCollectDeviceResourceCode(HzhrTypeUtil.string2string(in.getCollectDeviceResourceCode()));
        result.setIotDeviceId(HzhrTypeUtil.integer2integer(in.getIotDeviceId()));
        result.setIotDeviceCode(HzhrTypeUtil.string2string(in.getIotDeviceCode()));
        result.setIotDeviceCategoryCode(HzhrTypeUtil.string2string(in.getIotDeviceCategoryCode()));
        result.setIotDeviceCompanyId(HzhrTypeUtil.integer2integer(in.getIotDeviceCompanyId()));
        result.setIotDeviceCompanyName(HzhrTypeUtil.string2string(in.getIotDeviceCompanyName()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        result.setGasUserCode(HzhrTypeUtil.string2string(in.getGasUserCode()));
        result.setExceptionDayCount(HzhrTypeUtil.integer2integer(in.getExceptionDayCount()));
        result.setExceptionType(HzhrTypeUtil.string2string(in.getExceptionType()));
        result.setStatisDate(HzhrTypeUtil.long2date(in.getStatisDate()));
        return result;
    }
    public List<DeviceDataExceptionEntity> deviceDataExceptionModelList2entityList(List<DeviceDataExceptionModel> in) {
        if (in == null) return null;
        List<DeviceDataExceptionEntity> result = new ArrayList<>();
        for (DeviceDataExceptionModel item : in) {
            result.add(deviceDataExceptionModel2entity(item));
        }
        return result;
    }
    public DeviceDataExceptionModel entity2deviceDataExceptionModel(DeviceDataExceptionEntity in) {
        //未转换字段: collectDeviceCategoryDes exceptionTypeDes 
        if (in == null) return null;
        DeviceDataExceptionModel result = new DeviceDataExceptionModel();

        result.setCollectDeviceId(HzhrTypeUtil.integer2integer(in.getCollectDeviceId()));
        result.setCollectDeviceCode(HzhrTypeUtil.string2string(in.getCollectDeviceCode()));
        result.setCollectDeviceCategoryCode(HzhrTypeUtil.string2string(in.getCollectDeviceCategoryCode()));
        result.setCollectDeviceDeptId(HzhrTypeUtil.integer2integer(in.getCollectDeviceDeptId()));
        result.setCollectDeviceDeptName(HzhrTypeUtil.string2string(in.getCollectDeviceDeptName()));
        result.setCollectDeviceResourceCode(HzhrTypeUtil.string2string(in.getCollectDeviceResourceCode()));
        result.setIotDeviceId(HzhrTypeUtil.integer2integer(in.getIotDeviceId()));
        result.setIotDeviceCode(HzhrTypeUtil.string2string(in.getIotDeviceCode()));
        result.setIotDeviceCategoryCode(HzhrTypeUtil.string2string(in.getIotDeviceCategoryCode()));
        result.setIotDeviceCompanyId(HzhrTypeUtil.integer2integer(in.getIotDeviceCompanyId()));
        result.setIotDeviceCompanyName(HzhrTypeUtil.string2string(in.getIotDeviceCompanyName()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        result.setGasUserCode(HzhrTypeUtil.string2string(in.getGasUserCode()));
        result.setExceptionDayCount(HzhrTypeUtil.integer2integer(in.getExceptionDayCount()));
        result.setExceptionType(HzhrTypeUtil.string2string(in.getExceptionType()));
        result.setStatisDate(HzhrTypeUtil.date2long(in.getStatisDate()));
        return result;
    }
    public List<DeviceDataExceptionModel> entityList2deviceDataExceptionModelList(List<DeviceDataExceptionEntity> in) {
        if (in == null) return null;
        List<DeviceDataExceptionModel> result = new ArrayList<>();
        for (DeviceDataExceptionEntity item : in) {
            result.add(entity2deviceDataExceptionModel(item));
        }
        return result;
    }
    public DeviceDataExceptionModel ext2deviceDataExceptionModel(DeviceDataExceptionEntityExt in) {
        //未转换字段: collectDeviceCategoryDes exceptionTypeDes 
        if (in == null) return null;
        DeviceDataExceptionModel result = new DeviceDataExceptionModel();

        result.setCollectDeviceId(HzhrTypeUtil.integer2integer(in.getCollectDeviceId()));
        result.setCollectDeviceCode(HzhrTypeUtil.string2string(in.getCollectDeviceCode()));
        result.setCollectDeviceCategoryCode(HzhrTypeUtil.string2string(in.getCollectDeviceCategoryCode()));
        result.setCollectDeviceDeptId(HzhrTypeUtil.integer2integer(in.getCollectDeviceDeptId()));
        result.setCollectDeviceDeptName(HzhrTypeUtil.string2string(in.getCollectDeviceDeptName()));
        result.setCollectDeviceResourceCode(HzhrTypeUtil.string2string(in.getCollectDeviceResourceCode()));
        result.setIotDeviceId(HzhrTypeUtil.integer2integer(in.getIotDeviceId()));
        result.setIotDeviceCode(HzhrTypeUtil.string2string(in.getIotDeviceCode()));
        result.setIotDeviceCategoryCode(HzhrTypeUtil.string2string(in.getIotDeviceCategoryCode()));
        result.setIotDeviceCompanyId(HzhrTypeUtil.integer2integer(in.getIotDeviceCompanyId()));
        result.setIotDeviceCompanyName(HzhrTypeUtil.string2string(in.getIotDeviceCompanyName()));
        result.setGasUserId(HzhrTypeUtil.integer2integer(in.getGasUserId()));
        result.setGasUserCode(HzhrTypeUtil.string2string(in.getGasUserCode()));
        result.setExceptionDayCount(HzhrTypeUtil.integer2integer(in.getExceptionDayCount()));
        result.setExceptionType(HzhrTypeUtil.string2string(in.getExceptionType()));
        result.setStatisDate(HzhrTypeUtil.date2long(in.getStatisDate()));
        return result;
    }
    public List<DeviceDataExceptionModel> extList2deviceDataExceptionModelList(List<DeviceDataExceptionEntityExt> in) {
        if (in == null) return null;
        List<DeviceDataExceptionModel> result = new ArrayList<>();
        for (DeviceDataExceptionEntityExt item : in) {
            result.add(ext2deviceDataExceptionModel(item));
        }
        return result;
    }
    public DeviceDataExceptionGetModel extList2deviceDataExceptionGetModel(List<DeviceDataExceptionEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<DeviceDataExceptionModel> modelList = extList2deviceDataExceptionModelList(extList);
        if (modelList == null) {
            DeviceDataExceptionGetModel result = new DeviceDataExceptionGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));


        DeviceDataExceptionGetModel result = new DeviceDataExceptionGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public DeviceDataExceptionGetModel entity2deviceDataExceptionGetModel(DeviceDataExceptionEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<DeviceDataExceptionEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2deviceDataExceptionGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, DeviceDataExceptionEntityExt.class));
        return extList2deviceDataExceptionGetModel(extList, total, changeCount, query);
     }
    public DeviceDataExceptionCustomQueryModel deviceDataExceptionService_query2queryModel(Map<String, Object> query) {
        DeviceDataExceptionCustomQueryModel queryModel = new DeviceDataExceptionCustomQueryModel();

        String _equal_exceptionType = HzhrTypeUtil.object2string(query.get("_equal_exceptionType"));
        if (_equal_exceptionType != null) {
            queryModel.setEqual_exceptionType(_equal_exceptionType);
         }

        Integer _greaterthanorequal_exceptionDayCount = HzhrTypeUtil.object2integer(query.get("_greaterthanorequal_exceptionDayCount"));
        if (_greaterthanorequal_exceptionDayCount != null) {
            queryModel.setGreaterthanorequal_exceptionDayCount(_greaterthanorequal_exceptionDayCount);
         }

        Date _greaterthanorequal_statisDate = HzhrTypeUtil.object2date(query.get("_greaterthanorequal_statisDate"));
        if (_greaterthanorequal_statisDate != null) {
            queryModel.setGreaterthanorequal_statisDate(_greaterthanorequal_statisDate);
         }

        Date _lessthan_statisDate = HzhrTypeUtil.object2date(query.get("_lessthan_statisDate"));
        if (_lessthan_statisDate != null) {
            queryModel.setLessthan_statisDate(_lessthan_statisDate);
         }

        Date _equal_statisDate = HzhrTypeUtil.object2date(query.get("_equal_statisDate"));
        if (_equal_statisDate != null) {
            queryModel.setEqual_statisDate(_equal_statisDate);
         }

        String _equal_collectDeviceCategoryCode = HzhrTypeUtil.object2string(query.get("_equal_collectDeviceCategoryCode"));
        if (_equal_collectDeviceCategoryCode != null) {
            queryModel.setEqual_collectDeviceCategoryCode(_equal_collectDeviceCategoryCode);
         }

        String _equal_collectDeviceId = HzhrTypeUtil.object2string(query.get("_equal_collectDeviceId"));
        if (_equal_collectDeviceId != null) {
            queryModel.setEqual_collectDeviceId(_equal_collectDeviceId);
         }

        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setShow(true);
        queryModel.setExt_exceptionTypeExt(true);
        queryModel.setShow3(true);
        queryModel.setShow(true);

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

